package alvarodelrosal.chat.server.modelo.chataction;

import alvarodelrosal.chat.server.infraestructura.ChatPersistenceManager;
import alvarodelrosal.chat.server.modelo.ChatConnection;
import alvarodelrosal.chat.server.modelo.ChatUser;
import java.util.List;

public class ChatAllUsers implements ChatAction {

    @Override
    public String getName() {
        return "AllUsers";
    }

    @Override
    public boolean needsAdminPrivileges() {
        return true;
    }

    @Override
    public boolean needsLogin() {
        return true;
    }

    @Override
    public String doAction(ChatConnection connection, List<String> parameters) {
        StringBuilder builder = new StringBuilder("AllUsers");
        List<ChatUser> users = ChatPersistenceManager.getPersistenceManager().getAllUsers();
        for (ChatUser user : users) {
            builder.append("<:@:>");
            builder.append(user.getUserId());
        }
        
        return builder.toString();
    }
    
}
